/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainScreen.java
 *
 * Created on Jan 25, 2012, 9:51:54 PM
 */
package org.p2psimulator.gui;

import java.util.List;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import org.p2psimulator.config.BehaviorConfig;
import org.p2psimulator.engine.MultipleScenarioSimulator;
import org.p2psimulator.engine.SingleScenarioSimulator;
import org.p2psimulator.gui.panel.*;

/**
 *
 * @author amorim
 */
public class MainScreen extends JFrame {

    private Thread automaticSimulationThread;
    private Thread singleScenarioSimulatorThread;
    private MultipleScenarioSimulator multipleScenarioSimulator;
    private SingleScenarioSimulator singleScenarioSimulator;
    
    /** Creates new form MainScreen */
    public MainScreen() {
        initComponents();
        
        behaviorConfigPanel.setMainFrame(this);
        toolBarPanel.setMainFrame(this);
        consoleLogger.setMainFrame(this);
        environmentConfigPanel.setMainFrame(this);
        monitorPanel.setMainFrame(this);
        statusPanel.setMainFrame(this);
        simulationConfigPanel.setMainFrame(this);
        
        
        setSize(900, 800);
        setLocation(100, 10);
        setVisible(true);
        //setExtendedState(JFrame.MAXIMIZED_BOTH);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        tabbedConfig = new javax.swing.JTabbedPane();
        simulationConfigPanel = new org.p2psimulator.gui.panel.SimulationConfigPanel();
        environmentConfigPanel = new org.p2psimulator.gui.panel.ProtocolConfigPanel();
        consoleLogger = new org.p2psimulator.gui.panel.ConsoleLogger();
        workTabbedPane = new javax.swing.JTabbedPane();
        behaviorConfigPanel = new org.p2psimulator.gui.panel.BehaviorConfigPanel();
        monitorPanel = new org.p2psimulator.gui.panel.MonitorPanel();
        jPanel2 = new javax.swing.JPanel();
        statusPanel = new org.p2psimulator.gui.panel.StatusPanel();
        jSeparator1 = new javax.swing.JSeparator();
        toolBarPanel = new org.p2psimulator.gui.panel.ToolBarPanel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("P2PRep - Simulator");

        jPanel1.setBackground(new java.awt.Color(225, 225, 225));
        jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));

        tabbedConfig.setBackground(new java.awt.Color(255, 255, 255));
        tabbedConfig.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        tabbedConfig.setMinimumSize(new java.awt.Dimension(175, 650));
        tabbedConfig.setPreferredSize(new java.awt.Dimension(200, 650));
        tabbedConfig.addTab("Simulation", simulationConfigPanel);
        tabbedConfig.addTab("Advanced", environmentConfigPanel);

        workTabbedPane.addTab("Scenario", new javax.swing.ImageIcon(getClass().getResource("/resources/behavior.png")), behaviorConfigPanel); // NOI18N
        workTabbedPane.addTab("Statistics", new javax.swing.ImageIcon(getClass().getResource("/resources/chart.png")), monitorPanel); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tabbedConfig, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(39, 39, 39)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(workTabbedPane)
                    .addComponent(consoleLogger, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(workTabbedPane)
                        .addGap(12, 12, 12)
                        .addComponent(consoleLogger, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(tabbedConfig, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        workTabbedPane.getAccessibleContext().setAccessibleName("");

        jPanel2.setBackground(new java.awt.Color(225, 225, 225));

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(statusPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 353, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(statusPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jMenuBar1.setBackground(new java.awt.Color(225, 225, 225));

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(toolBarPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(toolBarPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainScreen().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.p2psimulator.gui.panel.BehaviorConfigPanel behaviorConfigPanel;
    private org.p2psimulator.gui.panel.ConsoleLogger consoleLogger;
    private org.p2psimulator.gui.panel.ProtocolConfigPanel environmentConfigPanel;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JSeparator jSeparator1;
    private org.p2psimulator.gui.panel.MonitorPanel monitorPanel;
    private org.p2psimulator.gui.panel.SimulationConfigPanel simulationConfigPanel;
    private org.p2psimulator.gui.panel.StatusPanel statusPanel;
    private javax.swing.JTabbedPane tabbedConfig;
    private org.p2psimulator.gui.panel.ToolBarPanel toolBarPanel;
    private javax.swing.JTabbedPane workTabbedPane;
    // End of variables declaration//GEN-END:variables

    public StatusPanel getStatusPanel() {
        return statusPanel;
    }

    public void setStatusPanel(StatusPanel statusPanel) {
        this.statusPanel = statusPanel;
    }
    
    public ConsoleLogger getConsoleLogger() {
        return this.consoleLogger;
    }

    public void setConsoleLogger(ConsoleLogger consoleLogger) {
        this.consoleLogger = consoleLogger;
    }

    public ProtocolConfigPanel getEnvironmentConfigPanel() {
        return this.environmentConfigPanel;
    }

    public void setEnvironmentConfigPanel(ProtocolConfigPanel environmentConfigPanel) {
        this.environmentConfigPanel = environmentConfigPanel;
    }

    public SimulationConfigPanel getSimulationConfigPanel() {
        return this.simulationConfigPanel;
    }

    public void setSimulationConfigPanel(SimulationConfigPanel simulationConfigPanel) {
        this.simulationConfigPanel = simulationConfigPanel;
    }

    public BehaviorConfigPanel getBehaviorConfigPanel() {
        return this.behaviorConfigPanel;
    }

    public void setBehaviorConfigPanel(BehaviorConfigPanel behaviorConfigPanel) {
        this.behaviorConfigPanel = behaviorConfigPanel;
    }

    public MonitorPanel getMonitorPanel() {
        return monitorPanel;
    }

    public void setMonitorPanel(MonitorPanel monitorPanel) {
        this.monitorPanel = monitorPanel;
    }

    public JTabbedPane getWorkTabbedPanel() {
        return this.workTabbedPane;
    }

    public void setWorkTabbedPanel(JTabbedPane workTabbedPanel) {
        this.workTabbedPane = workTabbedPanel;
    }
    
    public ToolBarPanel getToolbarPanel(){
        return toolBarPanel;
    }

    public Thread getAutomaticSimulationThread() {
        return automaticSimulationThread;
    }

    public void setAutomaticSimulationThread(Thread automaticSimulationThread) {
        this.automaticSimulationThread = automaticSimulationThread;
    }

    public MultipleScenarioSimulator getMultipleScenarioSimulator() {
        return multipleScenarioSimulator;
    }

    public void setMultipleScenarioSimulator(MultipleScenarioSimulator multipleScenarioSimulator) {
        this.multipleScenarioSimulator = multipleScenarioSimulator;
    }

    public SingleScenarioSimulator getSingleScenarioSimulator() {
        return singleScenarioSimulator;
    }

    public void setSingleScenarioSimulator(SingleScenarioSimulator singleScenarioSimulator) {
        this.singleScenarioSimulator = singleScenarioSimulator;
    }

    public Thread getSingleScenarioSimulatorThread() {
        return singleScenarioSimulatorThread;
    }

    public void setSingleScenarioSimulatorThread(Thread singleScenarioSimulatorThread) {
        this.singleScenarioSimulatorThread = singleScenarioSimulatorThread;
    }    
}
